// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

pub mod analytics_service {
    use crate::Result;

    /// A builder for [AnalyticsService][crate::client::AnalyticsService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_retail_v2::*;
    /// # use builder::analytics_service::ClientBuilder;
    /// # use client::AnalyticsService;
    /// let builder : ClientBuilder = AnalyticsService::builder();
    /// let client = builder
    ///     .with_endpoint("https://retail.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::AnalyticsService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = AnalyticsService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::AnalyticsService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::AnalyticsService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::AnalyticsService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [AnalyticsService::export_analytics_metrics][crate::client::AnalyticsService::export_analytics_metrics] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::analytics_service::ExportAnalyticsMetrics;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ExportAnalyticsMetrics {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ExportAnalyticsMetrics(RequestBuilder<crate::model::ExportAnalyticsMetricsRequest>);

    impl ExportAnalyticsMetrics {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::AnalyticsService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ExportAnalyticsMetricsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [export_analytics_metrics][crate::client::AnalyticsService::export_analytics_metrics].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .export_analytics_metrics(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `export_analytics_metrics`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::ExportAnalyticsMetricsResponse, crate::model::ExportMetadata>
        {
            type Operation = lro::internal::Operation<
                crate::model::ExportAnalyticsMetricsResponse,
                crate::model::ExportMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [catalog][crate::model::ExportAnalyticsMetricsRequest::catalog].
        ///
        /// This is a **required** field for requests.
        pub fn set_catalog<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.catalog = v.into();
            self
        }

        /// Sets the value of [output_config][crate::model::ExportAnalyticsMetricsRequest::output_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_output_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::OutputConfig>,
        {
            self.0.request.output_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [output_config][crate::model::ExportAnalyticsMetricsRequest::output_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_output_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::OutputConfig>,
        {
            self.0.request.output_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [filter][crate::model::ExportAnalyticsMetricsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ExportAnalyticsMetrics {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [AnalyticsService::list_operations][crate::client::AnalyticsService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::analytics_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::AnalyticsService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [AnalyticsService::get_operation][crate::client::AnalyticsService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::analytics_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::AnalyticsService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

pub mod catalog_service {
    use crate::Result;

    /// A builder for [CatalogService][crate::client::CatalogService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_retail_v2::*;
    /// # use builder::catalog_service::ClientBuilder;
    /// # use client::CatalogService;
    /// let builder : ClientBuilder = CatalogService::builder();
    /// let client = builder
    ///     .with_endpoint("https://retail.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::CatalogService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = CatalogService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::CatalogService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::CatalogService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CatalogService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [CatalogService::list_catalogs][crate::client::CatalogService::list_catalogs] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::catalog_service::ListCatalogs;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListCatalogs {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListCatalogs(RequestBuilder<crate::model::ListCatalogsRequest>);

    impl ListCatalogs {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CatalogService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListCatalogsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListCatalogsResponse> {
            (*self.0.stub)
                .list_catalogs(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListCatalogsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListCatalogsResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [parent][crate::model::ListCatalogsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListCatalogsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListCatalogsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListCatalogs {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CatalogService::update_catalog][crate::client::CatalogService::update_catalog] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::catalog_service::UpdateCatalog;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateCatalog {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateCatalog(RequestBuilder<crate::model::UpdateCatalogRequest>);

    impl UpdateCatalog {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CatalogService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateCatalogRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Catalog> {
            (*self.0.stub)
                .update_catalog(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [catalog][crate::model::UpdateCatalogRequest::catalog].
        ///
        /// This is a **required** field for requests.
        pub fn set_catalog<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Catalog>,
        {
            self.0.request.catalog = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [catalog][crate::model::UpdateCatalogRequest::catalog].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_catalog<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Catalog>,
        {
            self.0.request.catalog = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::UpdateCatalogRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateCatalogRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateCatalog {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CatalogService::set_default_branch][crate::client::CatalogService::set_default_branch] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::catalog_service::SetDefaultBranch;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> SetDefaultBranch {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct SetDefaultBranch(RequestBuilder<crate::model::SetDefaultBranchRequest>);

    impl SetDefaultBranch {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CatalogService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::SetDefaultBranchRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .set_default_branch(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [catalog][crate::model::SetDefaultBranchRequest::catalog].
        pub fn set_catalog<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.catalog = v.into();
            self
        }

        /// Sets the value of [branch_id][crate::model::SetDefaultBranchRequest::branch_id].
        pub fn set_branch_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.branch_id = v.into();
            self
        }

        /// Sets the value of [note][crate::model::SetDefaultBranchRequest::note].
        pub fn set_note<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.note = v.into();
            self
        }

        /// Sets the value of [force][crate::model::SetDefaultBranchRequest::force].
        pub fn set_force<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.force = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for SetDefaultBranch {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CatalogService::get_default_branch][crate::client::CatalogService::get_default_branch] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::catalog_service::GetDefaultBranch;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetDefaultBranch {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetDefaultBranch(RequestBuilder<crate::model::GetDefaultBranchRequest>);

    impl GetDefaultBranch {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CatalogService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetDefaultBranchRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::GetDefaultBranchResponse> {
            (*self.0.stub)
                .get_default_branch(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [catalog][crate::model::GetDefaultBranchRequest::catalog].
        pub fn set_catalog<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.catalog = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetDefaultBranch {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CatalogService::get_completion_config][crate::client::CatalogService::get_completion_config] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::catalog_service::GetCompletionConfig;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetCompletionConfig {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetCompletionConfig(RequestBuilder<crate::model::GetCompletionConfigRequest>);

    impl GetCompletionConfig {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CatalogService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetCompletionConfigRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::CompletionConfig> {
            (*self.0.stub)
                .get_completion_config(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetCompletionConfigRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetCompletionConfig {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CatalogService::update_completion_config][crate::client::CatalogService::update_completion_config] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::catalog_service::UpdateCompletionConfig;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateCompletionConfig {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateCompletionConfig(RequestBuilder<crate::model::UpdateCompletionConfigRequest>);

    impl UpdateCompletionConfig {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CatalogService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateCompletionConfigRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::CompletionConfig> {
            (*self.0.stub)
                .update_completion_config(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [completion_config][crate::model::UpdateCompletionConfigRequest::completion_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_completion_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::CompletionConfig>,
        {
            self.0.request.completion_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [completion_config][crate::model::UpdateCompletionConfigRequest::completion_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_completion_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::CompletionConfig>,
        {
            self.0.request.completion_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::UpdateCompletionConfigRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateCompletionConfigRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateCompletionConfig {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CatalogService::get_attributes_config][crate::client::CatalogService::get_attributes_config] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::catalog_service::GetAttributesConfig;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetAttributesConfig {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetAttributesConfig(RequestBuilder<crate::model::GetAttributesConfigRequest>);

    impl GetAttributesConfig {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CatalogService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetAttributesConfigRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::AttributesConfig> {
            (*self.0.stub)
                .get_attributes_config(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetAttributesConfigRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetAttributesConfig {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CatalogService::update_attributes_config][crate::client::CatalogService::update_attributes_config] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::catalog_service::UpdateAttributesConfig;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateAttributesConfig {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateAttributesConfig(RequestBuilder<crate::model::UpdateAttributesConfigRequest>);

    impl UpdateAttributesConfig {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CatalogService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateAttributesConfigRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::AttributesConfig> {
            (*self.0.stub)
                .update_attributes_config(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [attributes_config][crate::model::UpdateAttributesConfigRequest::attributes_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_attributes_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::AttributesConfig>,
        {
            self.0.request.attributes_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [attributes_config][crate::model::UpdateAttributesConfigRequest::attributes_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_attributes_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::AttributesConfig>,
        {
            self.0.request.attributes_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::UpdateAttributesConfigRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateAttributesConfigRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateAttributesConfig {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CatalogService::add_catalog_attribute][crate::client::CatalogService::add_catalog_attribute] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::catalog_service::AddCatalogAttribute;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> AddCatalogAttribute {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct AddCatalogAttribute(RequestBuilder<crate::model::AddCatalogAttributeRequest>);

    impl AddCatalogAttribute {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CatalogService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::AddCatalogAttributeRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::AttributesConfig> {
            (*self.0.stub)
                .add_catalog_attribute(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [attributes_config][crate::model::AddCatalogAttributeRequest::attributes_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_attributes_config<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.attributes_config = v.into();
            self
        }

        /// Sets the value of [catalog_attribute][crate::model::AddCatalogAttributeRequest::catalog_attribute].
        ///
        /// This is a **required** field for requests.
        pub fn set_catalog_attribute<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::CatalogAttribute>,
        {
            self.0.request.catalog_attribute = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [catalog_attribute][crate::model::AddCatalogAttributeRequest::catalog_attribute].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_catalog_attribute<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::CatalogAttribute>,
        {
            self.0.request.catalog_attribute = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for AddCatalogAttribute {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CatalogService::remove_catalog_attribute][crate::client::CatalogService::remove_catalog_attribute] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::catalog_service::RemoveCatalogAttribute;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> RemoveCatalogAttribute {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct RemoveCatalogAttribute(RequestBuilder<crate::model::RemoveCatalogAttributeRequest>);

    impl RemoveCatalogAttribute {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CatalogService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::RemoveCatalogAttributeRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::AttributesConfig> {
            (*self.0.stub)
                .remove_catalog_attribute(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [attributes_config][crate::model::RemoveCatalogAttributeRequest::attributes_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_attributes_config<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.attributes_config = v.into();
            self
        }

        /// Sets the value of [key][crate::model::RemoveCatalogAttributeRequest::key].
        ///
        /// This is a **required** field for requests.
        pub fn set_key<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.key = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for RemoveCatalogAttribute {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CatalogService::replace_catalog_attribute][crate::client::CatalogService::replace_catalog_attribute] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::catalog_service::ReplaceCatalogAttribute;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ReplaceCatalogAttribute {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ReplaceCatalogAttribute(
        RequestBuilder<crate::model::ReplaceCatalogAttributeRequest>,
    );

    impl ReplaceCatalogAttribute {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CatalogService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ReplaceCatalogAttributeRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::AttributesConfig> {
            (*self.0.stub)
                .replace_catalog_attribute(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [attributes_config][crate::model::ReplaceCatalogAttributeRequest::attributes_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_attributes_config<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.attributes_config = v.into();
            self
        }

        /// Sets the value of [catalog_attribute][crate::model::ReplaceCatalogAttributeRequest::catalog_attribute].
        ///
        /// This is a **required** field for requests.
        pub fn set_catalog_attribute<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::CatalogAttribute>,
        {
            self.0.request.catalog_attribute = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [catalog_attribute][crate::model::ReplaceCatalogAttributeRequest::catalog_attribute].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_catalog_attribute<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::CatalogAttribute>,
        {
            self.0.request.catalog_attribute = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::ReplaceCatalogAttributeRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::ReplaceCatalogAttributeRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ReplaceCatalogAttribute {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CatalogService::list_operations][crate::client::CatalogService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::catalog_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CatalogService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CatalogService::get_operation][crate::client::CatalogService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::catalog_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CatalogService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

pub mod completion_service {
    use crate::Result;

    /// A builder for [CompletionService][crate::client::CompletionService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_retail_v2::*;
    /// # use builder::completion_service::ClientBuilder;
    /// # use client::CompletionService;
    /// let builder : ClientBuilder = CompletionService::builder();
    /// let client = builder
    ///     .with_endpoint("https://retail.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::CompletionService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = CompletionService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::CompletionService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::CompletionService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CompletionService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [CompletionService::complete_query][crate::client::CompletionService::complete_query] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::completion_service::CompleteQuery;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CompleteQuery {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CompleteQuery(RequestBuilder<crate::model::CompleteQueryRequest>);

    impl CompleteQuery {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CompletionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CompleteQueryRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::CompleteQueryResponse> {
            (*self.0.stub)
                .complete_query(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [catalog][crate::model::CompleteQueryRequest::catalog].
        ///
        /// This is a **required** field for requests.
        pub fn set_catalog<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.catalog = v.into();
            self
        }

        /// Sets the value of [query][crate::model::CompleteQueryRequest::query].
        ///
        /// This is a **required** field for requests.
        pub fn set_query<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.query = v.into();
            self
        }

        /// Sets the value of [visitor_id][crate::model::CompleteQueryRequest::visitor_id].
        pub fn set_visitor_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.visitor_id = v.into();
            self
        }

        /// Sets the value of [language_codes][crate::model::CompleteQueryRequest::language_codes].
        pub fn set_language_codes<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.0.request.language_codes = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [device_type][crate::model::CompleteQueryRequest::device_type].
        pub fn set_device_type<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.device_type = v.into();
            self
        }

        /// Sets the value of [dataset][crate::model::CompleteQueryRequest::dataset].
        pub fn set_dataset<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.dataset = v.into();
            self
        }

        /// Sets the value of [max_suggestions][crate::model::CompleteQueryRequest::max_suggestions].
        pub fn set_max_suggestions<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.max_suggestions = v.into();
            self
        }

        /// Sets the value of [enable_attribute_suggestions][crate::model::CompleteQueryRequest::enable_attribute_suggestions].
        pub fn set_enable_attribute_suggestions<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.enable_attribute_suggestions = v.into();
            self
        }

        /// Sets the value of [entity][crate::model::CompleteQueryRequest::entity].
        pub fn set_entity<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.entity = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CompleteQuery {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CompletionService::import_completion_data][crate::client::CompletionService::import_completion_data] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::completion_service::ImportCompletionData;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ImportCompletionData {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ImportCompletionData(RequestBuilder<crate::model::ImportCompletionDataRequest>);

    impl ImportCompletionData {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CompletionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ImportCompletionDataRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [import_completion_data][crate::client::CompletionService::import_completion_data].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .import_completion_data(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `import_completion_data`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::ImportCompletionDataResponse, crate::model::ImportMetadata>
        {
            type Operation = lro::internal::Operation<
                crate::model::ImportCompletionDataResponse,
                crate::model::ImportMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::ImportCompletionDataRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [input_config][crate::model::ImportCompletionDataRequest::input_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_input_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::CompletionDataInputConfig>,
        {
            self.0.request.input_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [input_config][crate::model::ImportCompletionDataRequest::input_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_input_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::CompletionDataInputConfig>,
        {
            self.0.request.input_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [notification_pubsub_topic][crate::model::ImportCompletionDataRequest::notification_pubsub_topic].
        pub fn set_notification_pubsub_topic<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.notification_pubsub_topic = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ImportCompletionData {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CompletionService::list_operations][crate::client::CompletionService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::completion_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CompletionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [CompletionService::get_operation][crate::client::CompletionService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::completion_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::CompletionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

pub mod control_service {
    use crate::Result;

    /// A builder for [ControlService][crate::client::ControlService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_retail_v2::*;
    /// # use builder::control_service::ClientBuilder;
    /// # use client::ControlService;
    /// let builder : ClientBuilder = ControlService::builder();
    /// let client = builder
    ///     .with_endpoint("https://retail.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::ControlService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = ControlService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::ControlService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::ControlService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ControlService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [ControlService::create_control][crate::client::ControlService::create_control] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::control_service::CreateControl;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateControl {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateControl(RequestBuilder<crate::model::CreateControlRequest>);

    impl CreateControl {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ControlService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateControlRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Control> {
            (*self.0.stub)
                .create_control(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::CreateControlRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [control][crate::model::CreateControlRequest::control].
        ///
        /// This is a **required** field for requests.
        pub fn set_control<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Control>,
        {
            self.0.request.control = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [control][crate::model::CreateControlRequest::control].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_control<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Control>,
        {
            self.0.request.control = v.map(|x| x.into());
            self
        }

        /// Sets the value of [control_id][crate::model::CreateControlRequest::control_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_control_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.control_id = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateControl {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ControlService::delete_control][crate::client::ControlService::delete_control] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::control_service::DeleteControl;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteControl {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteControl(RequestBuilder<crate::model::DeleteControlRequest>);

    impl DeleteControl {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ControlService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteControlRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .delete_control(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::DeleteControlRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteControl {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ControlService::update_control][crate::client::ControlService::update_control] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::control_service::UpdateControl;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateControl {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateControl(RequestBuilder<crate::model::UpdateControlRequest>);

    impl UpdateControl {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ControlService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateControlRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Control> {
            (*self.0.stub)
                .update_control(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [control][crate::model::UpdateControlRequest::control].
        ///
        /// This is a **required** field for requests.
        pub fn set_control<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Control>,
        {
            self.0.request.control = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [control][crate::model::UpdateControlRequest::control].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_control<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Control>,
        {
            self.0.request.control = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::UpdateControlRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateControlRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateControl {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ControlService::get_control][crate::client::ControlService::get_control] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::control_service::GetControl;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetControl {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetControl(RequestBuilder<crate::model::GetControlRequest>);

    impl GetControl {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ControlService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetControlRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Control> {
            (*self.0.stub)
                .get_control(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetControlRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetControl {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ControlService::list_controls][crate::client::ControlService::list_controls] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::control_service::ListControls;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListControls {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListControls(RequestBuilder<crate::model::ListControlsRequest>);

    impl ListControls {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ControlService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListControlsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListControlsResponse> {
            (*self.0.stub)
                .list_controls(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListControlsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListControlsResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [parent][crate::model::ListControlsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListControlsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListControlsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [filter][crate::model::ListControlsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListControls {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ControlService::list_operations][crate::client::ControlService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::control_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ControlService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ControlService::get_operation][crate::client::ControlService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::control_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ControlService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

pub mod conversational_search_service {
    use crate::Result;

    /// A builder for [ConversationalSearchService][crate::client::ConversationalSearchService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_retail_v2::*;
    /// # use builder::conversational_search_service::ClientBuilder;
    /// # use client::ConversationalSearchService;
    /// let builder : ClientBuilder = ConversationalSearchService::builder();
    /// let client = builder
    ///     .with_endpoint("https://retail.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::ConversationalSearchService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = ConversationalSearchService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::ConversationalSearchService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [ConversationalSearchService::list_operations][crate::client::ConversationalSearchService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::conversational_search_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ConversationalSearchService::get_operation][crate::client::ConversationalSearchService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::conversational_search_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ConversationalSearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

pub mod generative_question_service {
    use crate::Result;

    /// A builder for [GenerativeQuestionService][crate::client::GenerativeQuestionService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_retail_v2::*;
    /// # use builder::generative_question_service::ClientBuilder;
    /// # use client::GenerativeQuestionService;
    /// let builder : ClientBuilder = GenerativeQuestionService::builder();
    /// let client = builder
    ///     .with_endpoint("https://retail.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::GenerativeQuestionService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = GenerativeQuestionService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::GenerativeQuestionService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::GenerativeQuestionService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::GenerativeQuestionService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [GenerativeQuestionService::update_generative_questions_feature_config][crate::client::GenerativeQuestionService::update_generative_questions_feature_config] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::generative_question_service::UpdateGenerativeQuestionsFeatureConfig;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateGenerativeQuestionsFeatureConfig {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateGenerativeQuestionsFeatureConfig(
        RequestBuilder<crate::model::UpdateGenerativeQuestionsFeatureConfigRequest>,
    );

    impl UpdateGenerativeQuestionsFeatureConfig {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::GenerativeQuestionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<
            V: Into<crate::model::UpdateGenerativeQuestionsFeatureConfigRequest>,
        >(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::GenerativeQuestionsFeatureConfig> {
            (*self.0.stub)
                .update_generative_questions_feature_config(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [generative_questions_feature_config][crate::model::UpdateGenerativeQuestionsFeatureConfigRequest::generative_questions_feature_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_generative_questions_feature_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::GenerativeQuestionsFeatureConfig>,
        {
            self.0.request.generative_questions_feature_config =
                std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [generative_questions_feature_config][crate::model::UpdateGenerativeQuestionsFeatureConfigRequest::generative_questions_feature_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_generative_questions_feature_config<T>(
            mut self,
            v: std::option::Option<T>,
        ) -> Self
        where
            T: std::convert::Into<crate::model::GenerativeQuestionsFeatureConfig>,
        {
            self.0.request.generative_questions_feature_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::UpdateGenerativeQuestionsFeatureConfigRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateGenerativeQuestionsFeatureConfigRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateGenerativeQuestionsFeatureConfig {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [GenerativeQuestionService::get_generative_questions_feature_config][crate::client::GenerativeQuestionService::get_generative_questions_feature_config] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::generative_question_service::GetGenerativeQuestionsFeatureConfig;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetGenerativeQuestionsFeatureConfig {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetGenerativeQuestionsFeatureConfig(
        RequestBuilder<crate::model::GetGenerativeQuestionsFeatureConfigRequest>,
    );

    impl GetGenerativeQuestionsFeatureConfig {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::GenerativeQuestionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetGenerativeQuestionsFeatureConfigRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::GenerativeQuestionsFeatureConfig> {
            (*self.0.stub)
                .get_generative_questions_feature_config(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [catalog][crate::model::GetGenerativeQuestionsFeatureConfigRequest::catalog].
        ///
        /// This is a **required** field for requests.
        pub fn set_catalog<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.catalog = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetGenerativeQuestionsFeatureConfig {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [GenerativeQuestionService::list_generative_question_configs][crate::client::GenerativeQuestionService::list_generative_question_configs] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::generative_question_service::ListGenerativeQuestionConfigs;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListGenerativeQuestionConfigs {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListGenerativeQuestionConfigs(
        RequestBuilder<crate::model::ListGenerativeQuestionConfigsRequest>,
    );

    impl ListGenerativeQuestionConfigs {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::GenerativeQuestionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListGenerativeQuestionConfigsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListGenerativeQuestionConfigsResponse> {
            (*self.0.stub)
                .list_generative_question_configs(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::ListGenerativeQuestionConfigsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListGenerativeQuestionConfigs {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [GenerativeQuestionService::update_generative_question_config][crate::client::GenerativeQuestionService::update_generative_question_config] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::generative_question_service::UpdateGenerativeQuestionConfig;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateGenerativeQuestionConfig {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateGenerativeQuestionConfig(
        RequestBuilder<crate::model::UpdateGenerativeQuestionConfigRequest>,
    );

    impl UpdateGenerativeQuestionConfig {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::GenerativeQuestionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateGenerativeQuestionConfigRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::GenerativeQuestionConfig> {
            (*self.0.stub)
                .update_generative_question_config(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [generative_question_config][crate::model::UpdateGenerativeQuestionConfigRequest::generative_question_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_generative_question_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::GenerativeQuestionConfig>,
        {
            self.0.request.generative_question_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [generative_question_config][crate::model::UpdateGenerativeQuestionConfigRequest::generative_question_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_generative_question_config<T>(
            mut self,
            v: std::option::Option<T>,
        ) -> Self
        where
            T: std::convert::Into<crate::model::GenerativeQuestionConfig>,
        {
            self.0.request.generative_question_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::UpdateGenerativeQuestionConfigRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateGenerativeQuestionConfigRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateGenerativeQuestionConfig {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [GenerativeQuestionService::batch_update_generative_question_configs][crate::client::GenerativeQuestionService::batch_update_generative_question_configs] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::generative_question_service::BatchUpdateGenerativeQuestionConfigs;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> BatchUpdateGenerativeQuestionConfigs {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct BatchUpdateGenerativeQuestionConfigs(
        RequestBuilder<crate::model::BatchUpdateGenerativeQuestionConfigsRequest>,
    );

    impl BatchUpdateGenerativeQuestionConfigs {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::GenerativeQuestionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::BatchUpdateGenerativeQuestionConfigsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(
            self,
        ) -> Result<crate::model::BatchUpdateGenerativeQuestionConfigsResponse> {
            (*self.0.stub)
                .batch_update_generative_question_configs(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::BatchUpdateGenerativeQuestionConfigsRequest::parent].
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [requests][crate::model::BatchUpdateGenerativeQuestionConfigsRequest::requests].
        ///
        /// This is a **required** field for requests.
        pub fn set_requests<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::UpdateGenerativeQuestionConfigRequest>,
        {
            use std::iter::Iterator;
            self.0.request.requests = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for BatchUpdateGenerativeQuestionConfigs {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [GenerativeQuestionService::list_operations][crate::client::GenerativeQuestionService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::generative_question_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::GenerativeQuestionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [GenerativeQuestionService::get_operation][crate::client::GenerativeQuestionService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::generative_question_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::GenerativeQuestionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

pub mod model_service {
    use crate::Result;

    /// A builder for [ModelService][crate::client::ModelService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_retail_v2::*;
    /// # use builder::model_service::ClientBuilder;
    /// # use client::ModelService;
    /// let builder : ClientBuilder = ModelService::builder();
    /// let client = builder
    ///     .with_endpoint("https://retail.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::ModelService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = ModelService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::ModelService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [ModelService::create_model][crate::client::ModelService::create_model] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::model_service::CreateModel;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateModel {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateModel(RequestBuilder<crate::model::CreateModelRequest>);

    impl CreateModel {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateModelRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [create_model][crate::client::ModelService::create_model].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .create_model(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `create_model`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::Model, crate::model::CreateModelMetadata> {
            type Operation =
                lro::internal::Operation<crate::model::Model, crate::model::CreateModelMetadata>;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::CreateModelRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [model][crate::model::CreateModelRequest::model].
        ///
        /// This is a **required** field for requests.
        pub fn set_model<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Model>,
        {
            self.0.request.model = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [model][crate::model::CreateModelRequest::model].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_model<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Model>,
        {
            self.0.request.model = v.map(|x| x.into());
            self
        }

        /// Sets the value of [dry_run][crate::model::CreateModelRequest::dry_run].
        pub fn set_dry_run<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.dry_run = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateModel {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ModelService::get_model][crate::client::ModelService::get_model] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::model_service::GetModel;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetModel {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetModel(RequestBuilder<crate::model::GetModelRequest>);

    impl GetModel {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetModelRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Model> {
            (*self.0.stub)
                .get_model(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetModelRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetModel {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ModelService::pause_model][crate::client::ModelService::pause_model] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::model_service::PauseModel;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> PauseModel {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct PauseModel(RequestBuilder<crate::model::PauseModelRequest>);

    impl PauseModel {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::PauseModelRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Model> {
            (*self.0.stub)
                .pause_model(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::PauseModelRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for PauseModel {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ModelService::resume_model][crate::client::ModelService::resume_model] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::model_service::ResumeModel;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ResumeModel {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ResumeModel(RequestBuilder<crate::model::ResumeModelRequest>);

    impl ResumeModel {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ResumeModelRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Model> {
            (*self.0.stub)
                .resume_model(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::ResumeModelRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ResumeModel {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ModelService::delete_model][crate::client::ModelService::delete_model] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::model_service::DeleteModel;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteModel {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteModel(RequestBuilder<crate::model::DeleteModelRequest>);

    impl DeleteModel {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteModelRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .delete_model(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::DeleteModelRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteModel {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ModelService::list_models][crate::client::ModelService::list_models] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::model_service::ListModels;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListModels {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListModels(RequestBuilder<crate::model::ListModelsRequest>);

    impl ListModels {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListModelsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListModelsResponse> {
            (*self.0.stub)
                .list_models(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListModelsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListModelsResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [parent][crate::model::ListModelsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListModelsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListModelsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListModels {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ModelService::update_model][crate::client::ModelService::update_model] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::model_service::UpdateModel;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateModel {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateModel(RequestBuilder<crate::model::UpdateModelRequest>);

    impl UpdateModel {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateModelRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Model> {
            (*self.0.stub)
                .update_model(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [model][crate::model::UpdateModelRequest::model].
        ///
        /// This is a **required** field for requests.
        pub fn set_model<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Model>,
        {
            self.0.request.model = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [model][crate::model::UpdateModelRequest::model].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_model<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Model>,
        {
            self.0.request.model = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::UpdateModelRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateModelRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateModel {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ModelService::tune_model][crate::client::ModelService::tune_model] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::model_service::TuneModel;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> TuneModel {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct TuneModel(RequestBuilder<crate::model::TuneModelRequest>);

    impl TuneModel {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::TuneModelRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [tune_model][crate::client::ModelService::tune_model].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .tune_model(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `tune_model`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::TuneModelResponse, crate::model::TuneModelMetadata>
        {
            type Operation = lro::internal::Operation<
                crate::model::TuneModelResponse,
                crate::model::TuneModelMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [name][crate::model::TuneModelRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for TuneModel {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ModelService::list_operations][crate::client::ModelService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::model_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ModelService::get_operation][crate::client::ModelService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::model_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

pub mod prediction_service {
    use crate::Result;

    /// A builder for [PredictionService][crate::client::PredictionService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_retail_v2::*;
    /// # use builder::prediction_service::ClientBuilder;
    /// # use client::PredictionService;
    /// let builder : ClientBuilder = PredictionService::builder();
    /// let client = builder
    ///     .with_endpoint("https://retail.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::PredictionService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = PredictionService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::PredictionService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::PredictionService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::PredictionService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [PredictionService::predict][crate::client::PredictionService::predict] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::prediction_service::Predict;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> Predict {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct Predict(RequestBuilder<crate::model::PredictRequest>);

    impl Predict {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::PredictionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::PredictRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::PredictResponse> {
            (*self.0.stub)
                .predict(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [placement][crate::model::PredictRequest::placement].
        ///
        /// This is a **required** field for requests.
        pub fn set_placement<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.placement = v.into();
            self
        }

        /// Sets the value of [user_event][crate::model::PredictRequest::user_event].
        ///
        /// This is a **required** field for requests.
        pub fn set_user_event<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::UserEvent>,
        {
            self.0.request.user_event = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [user_event][crate::model::PredictRequest::user_event].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_user_event<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::UserEvent>,
        {
            self.0.request.user_event = v.map(|x| x.into());
            self
        }

        /// Sets the value of [page_size][crate::model::PredictRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::PredictRequest::page_token].
        #[deprecated]
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [filter][crate::model::PredictRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [validate_only][crate::model::PredictRequest::validate_only].
        pub fn set_validate_only<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.validate_only = v.into();
            self
        }

        /// Sets the value of [params][crate::model::PredictRequest::params].
        pub fn set_params<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<wkt::Value>,
        {
            self.0.request.params = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }

        /// Sets the value of [labels][crate::model::PredictRequest::labels].
        pub fn set_labels<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<std::string::String>,
        {
            self.0.request.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for Predict {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [PredictionService::list_operations][crate::client::PredictionService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::prediction_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::PredictionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [PredictionService::get_operation][crate::client::PredictionService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::prediction_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::PredictionService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

pub mod product_service {
    use crate::Result;

    /// A builder for [ProductService][crate::client::ProductService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_retail_v2::*;
    /// # use builder::product_service::ClientBuilder;
    /// # use client::ProductService;
    /// let builder : ClientBuilder = ProductService::builder();
    /// let client = builder
    ///     .with_endpoint("https://retail.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::ProductService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = ProductService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::ProductService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::ProductService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProductService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [ProductService::create_product][crate::client::ProductService::create_product] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::product_service::CreateProduct;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateProduct {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateProduct(RequestBuilder<crate::model::CreateProductRequest>);

    impl CreateProduct {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProductService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateProductRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Product> {
            (*self.0.stub)
                .create_product(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::CreateProductRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [product][crate::model::CreateProductRequest::product].
        ///
        /// This is a **required** field for requests.
        pub fn set_product<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Product>,
        {
            self.0.request.product = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [product][crate::model::CreateProductRequest::product].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_product<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Product>,
        {
            self.0.request.product = v.map(|x| x.into());
            self
        }

        /// Sets the value of [product_id][crate::model::CreateProductRequest::product_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_product_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.product_id = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateProduct {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ProductService::get_product][crate::client::ProductService::get_product] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::product_service::GetProduct;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetProduct {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetProduct(RequestBuilder<crate::model::GetProductRequest>);

    impl GetProduct {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProductService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetProductRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Product> {
            (*self.0.stub)
                .get_product(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetProductRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetProduct {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ProductService::list_products][crate::client::ProductService::list_products] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::product_service::ListProducts;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListProducts {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListProducts(RequestBuilder<crate::model::ListProductsRequest>);

    impl ListProducts {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProductService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListProductsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListProductsResponse> {
            (*self.0.stub)
                .list_products(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListProductsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListProductsResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [parent][crate::model::ListProductsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListProductsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListProductsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [filter][crate::model::ListProductsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [read_mask][crate::model::ListProductsRequest::read_mask].
        pub fn set_read_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.read_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [read_mask][crate::model::ListProductsRequest::read_mask].
        pub fn set_or_clear_read_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.read_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListProducts {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ProductService::update_product][crate::client::ProductService::update_product] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::product_service::UpdateProduct;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateProduct {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateProduct(RequestBuilder<crate::model::UpdateProductRequest>);

    impl UpdateProduct {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProductService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateProductRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Product> {
            (*self.0.stub)
                .update_product(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [product][crate::model::UpdateProductRequest::product].
        ///
        /// This is a **required** field for requests.
        pub fn set_product<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Product>,
        {
            self.0.request.product = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [product][crate::model::UpdateProductRequest::product].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_product<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Product>,
        {
            self.0.request.product = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::UpdateProductRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateProductRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }

        /// Sets the value of [allow_missing][crate::model::UpdateProductRequest::allow_missing].
        pub fn set_allow_missing<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.allow_missing = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateProduct {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ProductService::delete_product][crate::client::ProductService::delete_product] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::product_service::DeleteProduct;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteProduct {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteProduct(RequestBuilder<crate::model::DeleteProductRequest>);

    impl DeleteProduct {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProductService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteProductRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .delete_product(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::DeleteProductRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteProduct {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ProductService::purge_products][crate::client::ProductService::purge_products] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::product_service::PurgeProducts;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> PurgeProducts {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct PurgeProducts(RequestBuilder<crate::model::PurgeProductsRequest>);

    impl PurgeProducts {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProductService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::PurgeProductsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [purge_products][crate::client::ProductService::purge_products].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .purge_products(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `purge_products`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::PurgeProductsResponse, crate::model::PurgeProductsMetadata>
        {
            type Operation = lro::internal::Operation<
                crate::model::PurgeProductsResponse,
                crate::model::PurgeProductsMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::PurgeProductsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [filter][crate::model::PurgeProductsRequest::filter].
        ///
        /// This is a **required** field for requests.
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [force][crate::model::PurgeProductsRequest::force].
        pub fn set_force<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.force = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for PurgeProducts {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ProductService::import_products][crate::client::ProductService::import_products] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::product_service::ImportProducts;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ImportProducts {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ImportProducts(RequestBuilder<crate::model::ImportProductsRequest>);

    impl ImportProducts {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProductService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ImportProductsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [import_products][crate::client::ProductService::import_products].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .import_products(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `import_products`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::ImportProductsResponse, crate::model::ImportMetadata>
        {
            type Operation = lro::internal::Operation<
                crate::model::ImportProductsResponse,
                crate::model::ImportMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::ImportProductsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [request_id][crate::model::ImportProductsRequest::request_id].
        #[deprecated]
        pub fn set_request_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.request_id = v.into();
            self
        }

        /// Sets the value of [input_config][crate::model::ImportProductsRequest::input_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_input_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::ProductInputConfig>,
        {
            self.0.request.input_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [input_config][crate::model::ImportProductsRequest::input_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_input_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::ProductInputConfig>,
        {
            self.0.request.input_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [errors_config][crate::model::ImportProductsRequest::errors_config].
        pub fn set_errors_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::ImportErrorsConfig>,
        {
            self.0.request.errors_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [errors_config][crate::model::ImportProductsRequest::errors_config].
        pub fn set_or_clear_errors_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::ImportErrorsConfig>,
        {
            self.0.request.errors_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::ImportProductsRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::ImportProductsRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }

        /// Sets the value of [reconciliation_mode][crate::model::ImportProductsRequest::reconciliation_mode].
        pub fn set_reconciliation_mode<
            T: Into<crate::model::import_products_request::ReconciliationMode>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.reconciliation_mode = v.into();
            self
        }

        /// Sets the value of [notification_pubsub_topic][crate::model::ImportProductsRequest::notification_pubsub_topic].
        pub fn set_notification_pubsub_topic<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.notification_pubsub_topic = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ImportProducts {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ProductService::set_inventory][crate::client::ProductService::set_inventory] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::product_service::SetInventory;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> SetInventory {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct SetInventory(RequestBuilder<crate::model::SetInventoryRequest>);

    impl SetInventory {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProductService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::SetInventoryRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [set_inventory][crate::client::ProductService::set_inventory].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .set_inventory(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `set_inventory`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::SetInventoryResponse, crate::model::SetInventoryMetadata>
        {
            type Operation = lro::internal::Operation<
                crate::model::SetInventoryResponse,
                crate::model::SetInventoryMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [inventory][crate::model::SetInventoryRequest::inventory].
        ///
        /// This is a **required** field for requests.
        pub fn set_inventory<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Product>,
        {
            self.0.request.inventory = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [inventory][crate::model::SetInventoryRequest::inventory].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_inventory<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Product>,
        {
            self.0.request.inventory = v.map(|x| x.into());
            self
        }

        /// Sets the value of [set_mask][crate::model::SetInventoryRequest::set_mask].
        pub fn set_set_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.set_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [set_mask][crate::model::SetInventoryRequest::set_mask].
        pub fn set_or_clear_set_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.set_mask = v.map(|x| x.into());
            self
        }

        /// Sets the value of [set_time][crate::model::SetInventoryRequest::set_time].
        pub fn set_set_time<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.0.request.set_time = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [set_time][crate::model::SetInventoryRequest::set_time].
        pub fn set_or_clear_set_time<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.0.request.set_time = v.map(|x| x.into());
            self
        }

        /// Sets the value of [allow_missing][crate::model::SetInventoryRequest::allow_missing].
        pub fn set_allow_missing<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.allow_missing = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for SetInventory {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ProductService::add_fulfillment_places][crate::client::ProductService::add_fulfillment_places] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::product_service::AddFulfillmentPlaces;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> AddFulfillmentPlaces {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct AddFulfillmentPlaces(RequestBuilder<crate::model::AddFulfillmentPlacesRequest>);

    impl AddFulfillmentPlaces {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProductService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::AddFulfillmentPlacesRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [add_fulfillment_places][crate::client::ProductService::add_fulfillment_places].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .add_fulfillment_places(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `add_fulfillment_places`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<
            crate::model::AddFulfillmentPlacesResponse,
            crate::model::AddFulfillmentPlacesMetadata,
        > {
            type Operation = lro::internal::Operation<
                crate::model::AddFulfillmentPlacesResponse,
                crate::model::AddFulfillmentPlacesMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [product][crate::model::AddFulfillmentPlacesRequest::product].
        ///
        /// This is a **required** field for requests.
        pub fn set_product<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.product = v.into();
            self
        }

        /// Sets the value of [r#type][crate::model::AddFulfillmentPlacesRequest::type].
        ///
        /// This is a **required** field for requests.
        pub fn set_type<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.r#type = v.into();
            self
        }

        /// Sets the value of [place_ids][crate::model::AddFulfillmentPlacesRequest::place_ids].
        ///
        /// This is a **required** field for requests.
        pub fn set_place_ids<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.0.request.place_ids = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [add_time][crate::model::AddFulfillmentPlacesRequest::add_time].
        pub fn set_add_time<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.0.request.add_time = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [add_time][crate::model::AddFulfillmentPlacesRequest::add_time].
        pub fn set_or_clear_add_time<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.0.request.add_time = v.map(|x| x.into());
            self
        }

        /// Sets the value of [allow_missing][crate::model::AddFulfillmentPlacesRequest::allow_missing].
        pub fn set_allow_missing<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.allow_missing = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for AddFulfillmentPlaces {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ProductService::remove_fulfillment_places][crate::client::ProductService::remove_fulfillment_places] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::product_service::RemoveFulfillmentPlaces;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> RemoveFulfillmentPlaces {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct RemoveFulfillmentPlaces(
        RequestBuilder<crate::model::RemoveFulfillmentPlacesRequest>,
    );

    impl RemoveFulfillmentPlaces {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProductService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::RemoveFulfillmentPlacesRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [remove_fulfillment_places][crate::client::ProductService::remove_fulfillment_places].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .remove_fulfillment_places(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `remove_fulfillment_places`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<
            crate::model::RemoveFulfillmentPlacesResponse,
            crate::model::RemoveFulfillmentPlacesMetadata,
        > {
            type Operation = lro::internal::Operation<
                crate::model::RemoveFulfillmentPlacesResponse,
                crate::model::RemoveFulfillmentPlacesMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [product][crate::model::RemoveFulfillmentPlacesRequest::product].
        ///
        /// This is a **required** field for requests.
        pub fn set_product<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.product = v.into();
            self
        }

        /// Sets the value of [r#type][crate::model::RemoveFulfillmentPlacesRequest::type].
        ///
        /// This is a **required** field for requests.
        pub fn set_type<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.r#type = v.into();
            self
        }

        /// Sets the value of [place_ids][crate::model::RemoveFulfillmentPlacesRequest::place_ids].
        ///
        /// This is a **required** field for requests.
        pub fn set_place_ids<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.0.request.place_ids = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [remove_time][crate::model::RemoveFulfillmentPlacesRequest::remove_time].
        pub fn set_remove_time<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.0.request.remove_time = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [remove_time][crate::model::RemoveFulfillmentPlacesRequest::remove_time].
        pub fn set_or_clear_remove_time<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.0.request.remove_time = v.map(|x| x.into());
            self
        }

        /// Sets the value of [allow_missing][crate::model::RemoveFulfillmentPlacesRequest::allow_missing].
        pub fn set_allow_missing<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.allow_missing = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for RemoveFulfillmentPlaces {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ProductService::add_local_inventories][crate::client::ProductService::add_local_inventories] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::product_service::AddLocalInventories;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> AddLocalInventories {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct AddLocalInventories(RequestBuilder<crate::model::AddLocalInventoriesRequest>);

    impl AddLocalInventories {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProductService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::AddLocalInventoriesRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [add_local_inventories][crate::client::ProductService::add_local_inventories].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .add_local_inventories(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `add_local_inventories`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<
            crate::model::AddLocalInventoriesResponse,
            crate::model::AddLocalInventoriesMetadata,
        > {
            type Operation = lro::internal::Operation<
                crate::model::AddLocalInventoriesResponse,
                crate::model::AddLocalInventoriesMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [product][crate::model::AddLocalInventoriesRequest::product].
        ///
        /// This is a **required** field for requests.
        pub fn set_product<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.product = v.into();
            self
        }

        /// Sets the value of [local_inventories][crate::model::AddLocalInventoriesRequest::local_inventories].
        ///
        /// This is a **required** field for requests.
        pub fn set_local_inventories<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::LocalInventory>,
        {
            use std::iter::Iterator;
            self.0.request.local_inventories = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [add_mask][crate::model::AddLocalInventoriesRequest::add_mask].
        pub fn set_add_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.add_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [add_mask][crate::model::AddLocalInventoriesRequest::add_mask].
        pub fn set_or_clear_add_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.add_mask = v.map(|x| x.into());
            self
        }

        /// Sets the value of [add_time][crate::model::AddLocalInventoriesRequest::add_time].
        pub fn set_add_time<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.0.request.add_time = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [add_time][crate::model::AddLocalInventoriesRequest::add_time].
        pub fn set_or_clear_add_time<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.0.request.add_time = v.map(|x| x.into());
            self
        }

        /// Sets the value of [allow_missing][crate::model::AddLocalInventoriesRequest::allow_missing].
        pub fn set_allow_missing<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.allow_missing = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for AddLocalInventories {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ProductService::remove_local_inventories][crate::client::ProductService::remove_local_inventories] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::product_service::RemoveLocalInventories;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> RemoveLocalInventories {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct RemoveLocalInventories(RequestBuilder<crate::model::RemoveLocalInventoriesRequest>);

    impl RemoveLocalInventories {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProductService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::RemoveLocalInventoriesRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [remove_local_inventories][crate::client::ProductService::remove_local_inventories].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .remove_local_inventories(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `remove_local_inventories`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<
            crate::model::RemoveLocalInventoriesResponse,
            crate::model::RemoveLocalInventoriesMetadata,
        > {
            type Operation = lro::internal::Operation<
                crate::model::RemoveLocalInventoriesResponse,
                crate::model::RemoveLocalInventoriesMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [product][crate::model::RemoveLocalInventoriesRequest::product].
        ///
        /// This is a **required** field for requests.
        pub fn set_product<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.product = v.into();
            self
        }

        /// Sets the value of [place_ids][crate::model::RemoveLocalInventoriesRequest::place_ids].
        ///
        /// This is a **required** field for requests.
        pub fn set_place_ids<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.0.request.place_ids = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [remove_time][crate::model::RemoveLocalInventoriesRequest::remove_time].
        pub fn set_remove_time<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.0.request.remove_time = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [remove_time][crate::model::RemoveLocalInventoriesRequest::remove_time].
        pub fn set_or_clear_remove_time<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::Timestamp>,
        {
            self.0.request.remove_time = v.map(|x| x.into());
            self
        }

        /// Sets the value of [allow_missing][crate::model::RemoveLocalInventoriesRequest::allow_missing].
        pub fn set_allow_missing<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.allow_missing = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for RemoveLocalInventories {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ProductService::list_operations][crate::client::ProductService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::product_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProductService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ProductService::get_operation][crate::client::ProductService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::product_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ProductService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

pub mod search_service {
    use crate::Result;

    /// A builder for [SearchService][crate::client::SearchService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_retail_v2::*;
    /// # use builder::search_service::ClientBuilder;
    /// # use client::SearchService;
    /// let builder : ClientBuilder = SearchService::builder();
    /// let client = builder
    ///     .with_endpoint("https://retail.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::SearchService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = SearchService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::SearchService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::SearchService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SearchService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [SearchService::search][crate::client::SearchService::search] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::search_service::Search;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> Search {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct Search(RequestBuilder<crate::model::SearchRequest>);

    impl Search {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::SearchRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::SearchResponse> {
            (*self.0.stub)
                .search(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::SearchResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::SearchResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [placement][crate::model::SearchRequest::placement].
        ///
        /// This is a **required** field for requests.
        pub fn set_placement<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.placement = v.into();
            self
        }

        /// Sets the value of [branch][crate::model::SearchRequest::branch].
        pub fn set_branch<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.branch = v.into();
            self
        }

        /// Sets the value of [query][crate::model::SearchRequest::query].
        pub fn set_query<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.query = v.into();
            self
        }

        /// Sets the value of [visitor_id][crate::model::SearchRequest::visitor_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_visitor_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.visitor_id = v.into();
            self
        }

        /// Sets the value of [user_info][crate::model::SearchRequest::user_info].
        pub fn set_user_info<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::UserInfo>,
        {
            self.0.request.user_info = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [user_info][crate::model::SearchRequest::user_info].
        pub fn set_or_clear_user_info<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::UserInfo>,
        {
            self.0.request.user_info = v.map(|x| x.into());
            self
        }

        /// Sets the value of [page_size][crate::model::SearchRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::SearchRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [offset][crate::model::SearchRequest::offset].
        pub fn set_offset<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.offset = v.into();
            self
        }

        /// Sets the value of [filter][crate::model::SearchRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [canonical_filter][crate::model::SearchRequest::canonical_filter].
        pub fn set_canonical_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.canonical_filter = v.into();
            self
        }

        /// Sets the value of [order_by][crate::model::SearchRequest::order_by].
        pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.order_by = v.into();
            self
        }

        /// Sets the value of [facet_specs][crate::model::SearchRequest::facet_specs].
        pub fn set_facet_specs<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::search_request::FacetSpec>,
        {
            use std::iter::Iterator;
            self.0.request.facet_specs = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [dynamic_facet_spec][crate::model::SearchRequest::dynamic_facet_spec].
        #[deprecated]
        pub fn set_dynamic_facet_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::DynamicFacetSpec>,
        {
            self.0.request.dynamic_facet_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [dynamic_facet_spec][crate::model::SearchRequest::dynamic_facet_spec].
        #[deprecated]
        pub fn set_or_clear_dynamic_facet_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::DynamicFacetSpec>,
        {
            self.0.request.dynamic_facet_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [boost_spec][crate::model::SearchRequest::boost_spec].
        pub fn set_boost_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::BoostSpec>,
        {
            self.0.request.boost_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [boost_spec][crate::model::SearchRequest::boost_spec].
        pub fn set_or_clear_boost_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::BoostSpec>,
        {
            self.0.request.boost_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [query_expansion_spec][crate::model::SearchRequest::query_expansion_spec].
        pub fn set_query_expansion_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::QueryExpansionSpec>,
        {
            self.0.request.query_expansion_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [query_expansion_spec][crate::model::SearchRequest::query_expansion_spec].
        pub fn set_or_clear_query_expansion_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::QueryExpansionSpec>,
        {
            self.0.request.query_expansion_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [variant_rollup_keys][crate::model::SearchRequest::variant_rollup_keys].
        pub fn set_variant_rollup_keys<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.0.request.variant_rollup_keys = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [page_categories][crate::model::SearchRequest::page_categories].
        pub fn set_page_categories<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.0.request.page_categories = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [search_mode][crate::model::SearchRequest::search_mode].
        pub fn set_search_mode<T: Into<crate::model::search_request::SearchMode>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.search_mode = v.into();
            self
        }

        /// Sets the value of [personalization_spec][crate::model::SearchRequest::personalization_spec].
        pub fn set_personalization_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::PersonalizationSpec>,
        {
            self.0.request.personalization_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [personalization_spec][crate::model::SearchRequest::personalization_spec].
        pub fn set_or_clear_personalization_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::PersonalizationSpec>,
        {
            self.0.request.personalization_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [labels][crate::model::SearchRequest::labels].
        pub fn set_labels<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<std::string::String>,
        {
            self.0.request.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }

        /// Sets the value of [spell_correction_spec][crate::model::SearchRequest::spell_correction_spec].
        pub fn set_spell_correction_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::SpellCorrectionSpec>,
        {
            self.0.request.spell_correction_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [spell_correction_spec][crate::model::SearchRequest::spell_correction_spec].
        pub fn set_or_clear_spell_correction_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::SpellCorrectionSpec>,
        {
            self.0.request.spell_correction_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [entity][crate::model::SearchRequest::entity].
        pub fn set_entity<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.entity = v.into();
            self
        }

        /// Sets the value of [conversational_search_spec][crate::model::SearchRequest::conversational_search_spec].
        pub fn set_conversational_search_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::ConversationalSearchSpec>,
        {
            self.0.request.conversational_search_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [conversational_search_spec][crate::model::SearchRequest::conversational_search_spec].
        pub fn set_or_clear_conversational_search_spec<T>(
            mut self,
            v: std::option::Option<T>,
        ) -> Self
        where
            T: std::convert::Into<crate::model::search_request::ConversationalSearchSpec>,
        {
            self.0.request.conversational_search_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [tile_navigation_spec][crate::model::SearchRequest::tile_navigation_spec].
        pub fn set_tile_navigation_spec<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::search_request::TileNavigationSpec>,
        {
            self.0.request.tile_navigation_spec = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [tile_navigation_spec][crate::model::SearchRequest::tile_navigation_spec].
        pub fn set_or_clear_tile_navigation_spec<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::search_request::TileNavigationSpec>,
        {
            self.0.request.tile_navigation_spec = v.map(|x| x.into());
            self
        }

        /// Sets the value of [language_code][crate::model::SearchRequest::language_code].
        pub fn set_language_code<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.language_code = v.into();
            self
        }

        /// Sets the value of [region_code][crate::model::SearchRequest::region_code].
        pub fn set_region_code<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.region_code = v.into();
            self
        }

        /// Sets the value of [place_id][crate::model::SearchRequest::place_id].
        pub fn set_place_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.place_id = v.into();
            self
        }

        /// Sets the value of [user_attributes][crate::model::SearchRequest::user_attributes].
        pub fn set_user_attributes<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<crate::model::StringList>,
        {
            self.0.request.user_attributes =
                v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for Search {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SearchService::list_operations][crate::client::SearchService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::search_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SearchService::get_operation][crate::client::SearchService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::search_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SearchService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

pub mod serving_config_service {
    use crate::Result;

    /// A builder for [ServingConfigService][crate::client::ServingConfigService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_retail_v2::*;
    /// # use builder::serving_config_service::ClientBuilder;
    /// # use client::ServingConfigService;
    /// let builder : ClientBuilder = ServingConfigService::builder();
    /// let client = builder
    ///     .with_endpoint("https://retail.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::ServingConfigService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = ServingConfigService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::ServingConfigService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::ServingConfigService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServingConfigService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [ServingConfigService::create_serving_config][crate::client::ServingConfigService::create_serving_config] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::serving_config_service::CreateServingConfig;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateServingConfig {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateServingConfig(RequestBuilder<crate::model::CreateServingConfigRequest>);

    impl CreateServingConfig {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServingConfigService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateServingConfigRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ServingConfig> {
            (*self.0.stub)
                .create_serving_config(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::CreateServingConfigRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [serving_config][crate::model::CreateServingConfigRequest::serving_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_serving_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::ServingConfig>,
        {
            self.0.request.serving_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [serving_config][crate::model::CreateServingConfigRequest::serving_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_serving_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::ServingConfig>,
        {
            self.0.request.serving_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [serving_config_id][crate::model::CreateServingConfigRequest::serving_config_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_serving_config_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.serving_config_id = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateServingConfig {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ServingConfigService::delete_serving_config][crate::client::ServingConfigService::delete_serving_config] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::serving_config_service::DeleteServingConfig;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteServingConfig {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteServingConfig(RequestBuilder<crate::model::DeleteServingConfigRequest>);

    impl DeleteServingConfig {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServingConfigService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteServingConfigRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .delete_serving_config(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::DeleteServingConfigRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteServingConfig {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ServingConfigService::update_serving_config][crate::client::ServingConfigService::update_serving_config] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::serving_config_service::UpdateServingConfig;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateServingConfig {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateServingConfig(RequestBuilder<crate::model::UpdateServingConfigRequest>);

    impl UpdateServingConfig {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServingConfigService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateServingConfigRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ServingConfig> {
            (*self.0.stub)
                .update_serving_config(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [serving_config][crate::model::UpdateServingConfigRequest::serving_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_serving_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::ServingConfig>,
        {
            self.0.request.serving_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [serving_config][crate::model::UpdateServingConfigRequest::serving_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_serving_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::ServingConfig>,
        {
            self.0.request.serving_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::UpdateServingConfigRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateServingConfigRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateServingConfig {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ServingConfigService::get_serving_config][crate::client::ServingConfigService::get_serving_config] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::serving_config_service::GetServingConfig;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetServingConfig {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetServingConfig(RequestBuilder<crate::model::GetServingConfigRequest>);

    impl GetServingConfig {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServingConfigService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetServingConfigRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ServingConfig> {
            (*self.0.stub)
                .get_serving_config(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetServingConfigRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetServingConfig {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ServingConfigService::list_serving_configs][crate::client::ServingConfigService::list_serving_configs] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::serving_config_service::ListServingConfigs;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListServingConfigs {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListServingConfigs(RequestBuilder<crate::model::ListServingConfigsRequest>);

    impl ListServingConfigs {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServingConfigService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListServingConfigsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListServingConfigsResponse> {
            (*self.0.stub)
                .list_serving_configs(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListServingConfigsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            crate::model::ListServingConfigsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [parent][crate::model::ListServingConfigsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListServingConfigsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListServingConfigsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListServingConfigs {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ServingConfigService::add_control][crate::client::ServingConfigService::add_control] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::serving_config_service::AddControl;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> AddControl {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct AddControl(RequestBuilder<crate::model::AddControlRequest>);

    impl AddControl {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServingConfigService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::AddControlRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ServingConfig> {
            (*self.0.stub)
                .add_control(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [serving_config][crate::model::AddControlRequest::serving_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_serving_config<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.serving_config = v.into();
            self
        }

        /// Sets the value of [control_id][crate::model::AddControlRequest::control_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_control_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.control_id = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for AddControl {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ServingConfigService::remove_control][crate::client::ServingConfigService::remove_control] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::serving_config_service::RemoveControl;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> RemoveControl {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct RemoveControl(RequestBuilder<crate::model::RemoveControlRequest>);

    impl RemoveControl {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServingConfigService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::RemoveControlRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ServingConfig> {
            (*self.0.stub)
                .remove_control(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [serving_config][crate::model::RemoveControlRequest::serving_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_serving_config<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.serving_config = v.into();
            self
        }

        /// Sets the value of [control_id][crate::model::RemoveControlRequest::control_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_control_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.control_id = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for RemoveControl {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ServingConfigService::list_operations][crate::client::ServingConfigService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::serving_config_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServingConfigService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [ServingConfigService::get_operation][crate::client::ServingConfigService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::serving_config_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::ServingConfigService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

pub mod user_event_service {
    use crate::Result;

    /// A builder for [UserEventService][crate::client::UserEventService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_retail_v2::*;
    /// # use builder::user_event_service::ClientBuilder;
    /// # use client::UserEventService;
    /// let builder : ClientBuilder = UserEventService::builder();
    /// let client = builder
    ///     .with_endpoint("https://retail.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::UserEventService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = UserEventService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::UserEventService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::UserEventService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserEventService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [UserEventService::write_user_event][crate::client::UserEventService::write_user_event] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::user_event_service::WriteUserEvent;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> WriteUserEvent {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct WriteUserEvent(RequestBuilder<crate::model::WriteUserEventRequest>);

    impl WriteUserEvent {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserEventService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::WriteUserEventRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::UserEvent> {
            (*self.0.stub)
                .write_user_event(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::WriteUserEventRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [user_event][crate::model::WriteUserEventRequest::user_event].
        ///
        /// This is a **required** field for requests.
        pub fn set_user_event<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::UserEvent>,
        {
            self.0.request.user_event = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [user_event][crate::model::WriteUserEventRequest::user_event].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_user_event<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::UserEvent>,
        {
            self.0.request.user_event = v.map(|x| x.into());
            self
        }

        /// Sets the value of [write_async][crate::model::WriteUserEventRequest::write_async].
        pub fn set_write_async<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.write_async = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for WriteUserEvent {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [UserEventService::collect_user_event][crate::client::UserEventService::collect_user_event] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::user_event_service::CollectUserEvent;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CollectUserEvent {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CollectUserEvent(RequestBuilder<crate::model::CollectUserEventRequest>);

    impl CollectUserEvent {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserEventService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CollectUserEventRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<api::model::HttpBody> {
            (*self.0.stub)
                .collect_user_event(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::CollectUserEventRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [user_event][crate::model::CollectUserEventRequest::user_event].
        ///
        /// This is a **required** field for requests.
        pub fn set_user_event<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.user_event = v.into();
            self
        }

        /// Sets the value of [uri][crate::model::CollectUserEventRequest::uri].
        pub fn set_uri<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.uri = v.into();
            self
        }

        /// Sets the value of [ets][crate::model::CollectUserEventRequest::ets].
        pub fn set_ets<T: Into<i64>>(mut self, v: T) -> Self {
            self.0.request.ets = v.into();
            self
        }

        /// Sets the value of [raw_json][crate::model::CollectUserEventRequest::raw_json].
        pub fn set_raw_json<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.raw_json = v.into();
            self
        }

        /// Sets the value of [conversion_rule][crate::model::CollectUserEventRequest::conversion_rule].
        ///
        /// Note that all the setters affecting `conversion_rule` are
        /// mutually exclusive.
        pub fn set_conversion_rule<
            T: Into<Option<crate::model::collect_user_event_request::ConversionRule>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.conversion_rule = v.into();
            self
        }

        /// Sets the value of [conversion_rule][crate::model::CollectUserEventRequest::conversion_rule]
        /// to hold a `PrebuiltRule`.
        ///
        /// Note that all the setters affecting `conversion_rule` are
        /// mutually exclusive.
        pub fn set_prebuilt_rule<T: std::convert::Into<std::string::String>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_prebuilt_rule(v);
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CollectUserEvent {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [UserEventService::purge_user_events][crate::client::UserEventService::purge_user_events] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::user_event_service::PurgeUserEvents;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> PurgeUserEvents {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct PurgeUserEvents(RequestBuilder<crate::model::PurgeUserEventsRequest>);

    impl PurgeUserEvents {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserEventService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::PurgeUserEventsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [purge_user_events][crate::client::UserEventService::purge_user_events].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .purge_user_events(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `purge_user_events`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::PurgeUserEventsResponse, crate::model::PurgeMetadata>
        {
            type Operation = lro::internal::Operation<
                crate::model::PurgeUserEventsResponse,
                crate::model::PurgeMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::PurgeUserEventsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [filter][crate::model::PurgeUserEventsRequest::filter].
        ///
        /// This is a **required** field for requests.
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [force][crate::model::PurgeUserEventsRequest::force].
        pub fn set_force<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.force = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for PurgeUserEvents {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [UserEventService::import_user_events][crate::client::UserEventService::import_user_events] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::user_event_service::ImportUserEvents;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ImportUserEvents {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ImportUserEvents(RequestBuilder<crate::model::ImportUserEventsRequest>);

    impl ImportUserEvents {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserEventService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ImportUserEventsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [import_user_events][crate::client::UserEventService::import_user_events].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .import_user_events(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `import_user_events`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<crate::model::ImportUserEventsResponse, crate::model::ImportMetadata>
        {
            type Operation = lro::internal::Operation<
                crate::model::ImportUserEventsResponse,
                crate::model::ImportMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::ImportUserEventsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [input_config][crate::model::ImportUserEventsRequest::input_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_input_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::UserEventInputConfig>,
        {
            self.0.request.input_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [input_config][crate::model::ImportUserEventsRequest::input_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_input_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::UserEventInputConfig>,
        {
            self.0.request.input_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [errors_config][crate::model::ImportUserEventsRequest::errors_config].
        pub fn set_errors_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::ImportErrorsConfig>,
        {
            self.0.request.errors_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [errors_config][crate::model::ImportUserEventsRequest::errors_config].
        pub fn set_or_clear_errors_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::ImportErrorsConfig>,
        {
            self.0.request.errors_config = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ImportUserEvents {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [UserEventService::rejoin_user_events][crate::client::UserEventService::rejoin_user_events] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::user_event_service::RejoinUserEvents;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> RejoinUserEvents {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct RejoinUserEvents(RequestBuilder<crate::model::RejoinUserEventsRequest>);

    impl RejoinUserEvents {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserEventService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::RejoinUserEventsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [rejoin_user_events][crate::client::UserEventService::rejoin_user_events].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .rejoin_user_events(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `rejoin_user_events`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<
            crate::model::RejoinUserEventsResponse,
            crate::model::RejoinUserEventsMetadata,
        > {
            type Operation = lro::internal::Operation<
                crate::model::RejoinUserEventsResponse,
                crate::model::RejoinUserEventsMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::RejoinUserEventsRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [user_event_rejoin_scope][crate::model::RejoinUserEventsRequest::user_event_rejoin_scope].
        pub fn set_user_event_rejoin_scope<
            T: Into<crate::model::rejoin_user_events_request::UserEventRejoinScope>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.user_event_rejoin_scope = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for RejoinUserEvents {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [UserEventService::list_operations][crate::client::UserEventService::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::user_event_service::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserEventService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [UserEventService::get_operation][crate::client::UserEventService::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_retail_v2::builder;
    /// use builder::user_event_service::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::UserEventService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}
